<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>反馈</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">  <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">AP费用反馈</h2>
    </div>
    <!-- 标题 -->
    <div >
    <form id="f1" class="form-inline">
    <input type="hidden" name="aid" value="{$aid}"/>
      <table class="table row-margin-top table-bordered bud_hei">
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >主题</label></td>
             <td colspan="7" class="font-bold">{$apply.title}</td>
          </tr>
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >原申请编号</label></td>
             <td>{$apply.no}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >类型</label></td>
             <td>AP费用</td>
             
          </tr>
           
          
      </table>
       <table class="table row-margin-top table-bordered text-center bud_hei" id="tb">
         <thead>
          <tr class="info">
	            
	             <th class="text-center">序号</th>
	            <th class="text-center">分区</th>
	            <th class="text-center">省份</th>
	            <th class="text-center">城市</th>
	            <th class="text-center">经销商</th>
	            <th class="text-center">系统</th>
	            <th class="text-center">网点</th>
	            <th class="text-center">品牌</th>
	            <th class="text-center">实际投入费用(元)</th>
	           	<th class="text-center">预计销量(元)</th> 
	           	<th class="text-center">预计费用率</th>
					    <th class="text-center">实际销量(元)</th> 
	           	<th class="text-center">实际费用率</th>
	           	<th class="text-center">活动描述</th>
             </tr>
         </thead>

		{volist name="applyde" id="vo"}
		<tr class="text-center">
		<input type="hidden" name="fenqu[]" value="{$vo.fenquid}"/><input type="hidden" name="sheng[]" value="{$vo.shengid}"/>
		<input type="hidden" name="shi[]" value="{$vo.shiid}"/><input type="hidden" name="jxs[]" value="{$vo.jxsid}"/>
		<input type="hidden" name="system[]" value="{$vo.systemid}"/><input type="hidden" name="net[]" value="{$vo.netid}"/>
		<input type="hidden" name="brand[]" value="{$vo.brandid}"/>
			<td>{$i}</td>
			<td>{$vo.fenqu}</td><td>{$vo.sheng}</td><td>{$vo.shi}</td><td>{$vo.jxs}</td><td>{$vo.system}</td><td>{$vo.net}</td><td>{$vo.brand}</td>
			<td class="num2">{$vo.pifuzonges}</td><td class="num2">{$vo.zong_xiaoliangs}</td><td><span class="num2">{$vo.yujifeiyonglv}</span>%</td>
			<td><input type="text" name="fankuixiaoliang[]" je="{$vo.pifuzonges}" class="form-control fankuixiaoliang num2i" value=""/></td> 
			<td></td>
			<td><input type="text" name="fankuiremark[]" class="form-control fankuiremark" value=""/></td> 
        </tr>
		{/volist}
		<tr>
            <td class="text-right" row="2" >备注</td>
            <td colspan="13" class="text-left">
                <textarea name="remark" id="" rows="2" class="form-control" style="width: 50%" ></textarea><span style="vertical-align: bottom;">(200)</span>
            </td>
        </tr>
      </table>
       </table>
         <table class="table table-bordered" style="margin:0;padding: 0">
          <tr>
           <td class="font-bold">本申请中包含<span>{$contfenqu}</span>个分区，{$contbrand}个品牌,{$contgys}个供应商,{$contfeiyong}个三级费用科目  
			其中{volist name="feiyongs" id="fys"}{$fys.title}:<span class="num2">{$fys.kezonge}</span>（元）&nbsp;&nbsp; {/volist}
			总预计未税费用:<span class="num2">{$contzonge}</span>  （元）&nbsp;&nbsp;      总预计销售量：<span class="num2">{$contzongxiao}</span>（元）
            </td>
          </tr>
      </table>
         <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                  
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
         <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
         <input type="hidden" name="state" id="ste"/>
        <input type="button" class="btn btn-success" value="保存为草稿" onclick="baocun(1);">
        <input type="button" class="btn btn-info" value="保存并提交流程" onclick="baocun(3);">
        <input type="button" class="btn btn-warning" value="返回" onclick="back();">
    </div>
</form>
    </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
   <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
         <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
 <script src="__STATIC__/layout/js/common.js"></script>
  <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script>
   var rt={$rt};
    $(".num2i").blur(function(){
                if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="";
                $(this).val(num);
                if(num==""){
                  $(this).parent().next().html("")
                }else{
                  var xiaoliang=parseFloat($(this).val())
                  var jine=parseFloat($(this).attr("je"))
                  var feiyonglv=jine/xiaoliang*100;
                  $(this).parent().next().html(feiyonglv.toFixed(2)+"%")
                }
            })
function baocun(state){
  $("#ste").val(state);
 
   $(".num2i").each(function(){
                if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="";
                $(this).val(num);
                if(num==""){
                  $(this).parent().next().html("")
                }else{
                  var xiaoliang=parseFloat($(this).val())
                  var jine=parseFloat($(this).attr("je"))
                  var feiyonglv=jine/xiaoliang*100;
                  $(this).parent().next().html(feiyonglv.toFixed(2))
                }
            })
	 //至少反馈一条
	 var flag=0;
	 $(".fankuixiaoliang").each(function(){
	 	if($(this).val()!=""){
	 		flag=1;
	 	}
	 })
	 if(flag==1){

	 	 $.ajax({
                        cache: true,
                        type: "POST",
                        url:"{:url('fankuichuli')}",
                        data:$('#f1').serialize(),// 你的formid
                        async: false,
                        error: function(requests) {
                            alert("Connection error");
                        },
                        success: function(datas) {
                        	//alert(datas);
                         var res1=JSON.parse(datas);
                          if(res1["state"]==1){
                            swal({
                            title: "完成",
                            text: "操作已成功",
                            type: "success"
                            },function(){
                              //history.back();
                              if(rt==0){
                                location.href="{:url('index')}";
                              }else if(rt==1){
                                location.href="{:url('apRtLeft')}";
                              }
                              
                            });

                                  }else{
                                    swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                                  }
                          }
                    });

	 }else{
	 	 				swal({
                            title: "错误",
                            text:  "至少反馈一条明细",
                            type: "warning"
                            });
	 }
}
  
</script>
     <!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
    <script>

    $(".fankuixiaoliang").blur(function(){
    	if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="";
                $(this).val(num);
    })
           $(document).ready(function(){
           	 
          		
             $(".num2").each(function(){
                if(!isNaN(parseFloat($(this).html())))
                 var num=parseFloat($(this).html()).toFixed(2);
                else
                    var num="0.00";
                $(this).html(num);
            })
               $(".num2i").each(function(){
                if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="";
                $(this).val(num);
            })
 
            
 
		});
      

       // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

       
    });
   function back(){
        //history.back();
                              if(rt==0){
                                location.href="{:url('index')}";
                              }else if(rt==1){
                                location.href="{:url('apRtLeft')}";
                              }
   }
    </script>
</body>

</html>
